package com.nasarius.bank.scorecard.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.nasarius.bank.scorecard.dao.SurveyQuestionsDAO;
import com.nasarius.bank.scorecard.domain.SurveyQuestions;
import com.nasarius.bank.scorecard.domain.SurveyQuestionsExample;
@Repository
public class SurveyQuestionsDAOImpl extends SqlMapClientDaoSupport implements SurveyQuestionsDAO {

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
	@Autowired
    public SurveyQuestionsDAOImpl(/*@Qualifier("sqlMapClient")*/SqlMapClient sqlMapClient) {
        super();
        setSqlMapClient(sqlMapClient);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
    public int countSurveyQuestionsByExample(SurveyQuestionsExample example) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("survey_questions.ibatorgenerated_countByExample", example);
        return count;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
    public int deleteSurveyQuestionsByExample(SurveyQuestionsExample example) {
        int rows = getSqlMapClientTemplate().delete("survey_questions.ibatorgenerated_deleteByExample", example);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
    public int deleteSurveyQuestionsByPrimaryKey(Integer surveyquestionid) {
        SurveyQuestions key = new SurveyQuestions();
        key.setSurveyquestionid(surveyquestionid);
        int rows = getSqlMapClientTemplate().delete("survey_questions.ibatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }
    
    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
    public int deleteSurveyQuestionsBySurveyId(Integer surveyid) {
        SurveyQuestions key = new SurveyQuestions();
        key.setSurveyid(surveyid);
        int rows = getSqlMapClientTemplate().delete("survey_questions.ibatorgenerated_deleteBySurveyId", key);
        return rows;
    }    

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
    public void insertSurveyQuestions(SurveyQuestions record) {
    	Integer orderId = (Integer)getSqlMapClientTemplate().queryForObject("survey_questions.ibatorgenerated_selectorderId", record.getSurveyid());
    	if (orderId == null){
    		orderId = new Integer(0);
    	}
    	orderId = Integer.valueOf(orderId.intValue()+1);
    	record.setOrderid(orderId);
        getSqlMapClientTemplate().insert("survey_questions.ibatorgenerated_insert", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
    public void insertSurveyQuestionsSelective(SurveyQuestions record) {
        getSqlMapClientTemplate().insert("survey_questions.ibatorgenerated_insertSelective", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
    @SuppressWarnings("unchecked")
    public List<SurveyQuestions> selectSurveyQuestionsByExample(SurveyQuestionsExample example) {
        List<SurveyQuestions> list = getSqlMapClientTemplate().queryForList("survey_questions.ibatorgenerated_selectByExample", example);
        return list;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
    public SurveyQuestions selectSurveyQuestionsByPrimaryKey(Integer surveyquestionid) {
        SurveyQuestions key = new SurveyQuestions();
        key.setSurveyquestionid(surveyquestionid);
        SurveyQuestions record = (SurveyQuestions) getSqlMapClientTemplate().queryForObject("survey_questions.ibatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
    public int updateSurveyQuestionsByExampleSelective(SurveyQuestions record, SurveyQuestionsExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("survey_questions.ibatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
    public int updateSurveyQuestionsByExample(SurveyQuestions record, SurveyQuestionsExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("survey_questions.ibatorgenerated_updateByExample", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
    public int updateSurveyQuestionsByPrimaryKeySelective(SurveyQuestions record) {
        int rows = getSqlMapClientTemplate().update("survey_questions.ibatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
    public int updateSurveyQuestionsByPrimaryKey(SurveyQuestions record) {
        int rows = getSqlMapClientTemplate().update("survey_questions.ibatorgenerated_updateByPrimaryKey", record);
        return rows;
    }

    /**
     * This class was generated by Apache iBATIS ibator.
     * This class corresponds to the database table survey_questions
     *
     * @ibatorgenerated Sun Mar 13 00:13:58 IST 2011
     */
    private static class UpdateByExampleParms extends SurveyQuestionsExample {
        private Object record;

        public UpdateByExampleParms(Object record, SurveyQuestionsExample example) {
            super(example);
            this.record = record;
        }

        @SuppressWarnings("unused")
		public Object getRecord() {
            return record;
        }
    }
    @SuppressWarnings("unchecked")
    public List<SurveyQuestions> selectSurveyQuestionsBySurveyID(Integer SurveyID) {
        List<SurveyQuestions> list = getSqlMapClientTemplate().queryForList("survey_questions.ibatorgenerated_selectBySurveyID", SurveyID);
        return list;
    }
}